package com.xsomnus.java_basic.bitops;

/**
 * @author 叶小夏
 * @since 2019-08-23 16:10
 */
public class RGB {

    public static final int MAX_HEX = 0xffffff;


    private int red;
    private int green;
    private int blue;


    private void checkVal(int... val) {
        for (int value : val) {
            if (value < 0 || value > 0xff) {
                throw new IllegalArgumentException("val must be between 0 and 255");
            }
        }
    }
    public RGB(int red, int green, int blue) {

        checkVal(red, green, blue);
        this.red = red;
        this.green = green;
        this.blue = blue;
    }


    public int getRed() {
        return red;
    }

    public int getGreen() {
        return green;
    }

    public int getBlue() {
        return blue;
    }

    @Override
    public String toString() {
        return "RGB{" +
                "red=" + red +
                ", green=" + green +
                ", blue=" + blue +
                '}';
    }
}
